/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package it.coraci.anag.gui.people.mr;

import it.coraci.anag.db.sql.entities.Person;
import java.awt.Color;
import java.awt.Component;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.ListCellRenderer;

/**
 *
 * @author Luca
 */
public class PeopleListRenderer extends JLabel implements ListCellRenderer<Person> {

    public PeopleListRenderer() {
        super();
        this.setOpaque(true);
    }

    @Override
    public Component getListCellRendererComponent(JList<? extends Person> list, Person value, int index, boolean isSelected, boolean cellHasFocus) {
        this.setText(value.getCognome() + " " + value.getNome());
        if (isSelected) {
            this.setBackground(Color.BLUE);
            this.setForeground(Color.YELLOW);
        } else {
            this.setBackground(Color.WHITE);
            this.setForeground(Color.BLACK);
        }
        return this;
    }

}
